package com.joy.conf.mvc;

import com.joy.common.sitmesh.WebSiteMeshFilter;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


@Configuration
public class WebMvcFilterConfig implements WebMvcConfigurer {

	private Logger logger = LogManager.getLogger(WebMvcFilterConfig.class);
	
	@Bean
	public FilterRegistrationBean<WebSiteMeshFilter> siteMeshFilter() {
		logger.info(" start WebMvcConfiguration => siteMeshFilter Function");
		FilterRegistrationBean<WebSiteMeshFilter> filter = new FilterRegistrationBean<WebSiteMeshFilter>();
		WebSiteMeshFilter siteMeshFilter = new WebSiteMeshFilter();
		filter.setEnabled(true);
		filter.setFilter(siteMeshFilter);
		filter.setName("sitemesh");
		filter.addUrlPatterns("/*");
		filter.setOrder(10);  
		
		return filter;
	}
	
}
